<?php

namespace App\Listeners;

use App\Events\Notice as NoticeEvent;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use App\Models\Notice as NoticeSystem;
use DB;

class Notice
{
    /**
     * Create the event listener.
     *
     * @return void
     */
    public function __construct()
    {
        //
    }

    /**
     * Handle the event.
     *
     * @param  MachineState  $event
     * @return void
     */
    public function handle(NoticeEvent $event)
    {   
        $user = $event->user;
        $message = $event->message;
        $notice['title'] = '报单审核结果';
        $notice['content'] = '报单提交资料审核已经通过,收到短信好,请及时联系客服';
        $notice['recipient'] = $user->id;
        $notice['type'] = 3;
        $notice_info = NoticeSystem::create($notice);
        if($notice_info){
            $notice_manager['manager_id'] = $user->id;
            $notice_manager['read_state'] = 0;
            $notice_manager['type'] = 3;
            $notice_info->notice_manager()->create($notice_manager);                
        }
    }
}
